#include <stdio.h>
#include <stdlib.h>
#include <mygetline.h>

int main(int argc,char **argv)
{
	FILE *fp,*fps;
	char *buff = NULL;
	size_t linesize = 0;
	fp = tmpfile();
	if(fp == NULL)
	{
		perror("tmpfile()");
		exit(1);
	}
	if(argc < 2)
	{
		fprintf(stderr,"usage:%s\n",argv[0]);
		exit(1);
	}

	fps = fopen(argv[1],"r");
	if(fps == NULL)
	{
		perror("fopen()");
		exit(1);
	}

	while(mygetline(&buff,&linesize,fps) >= 0)
	{
		fputs(buff,fp);	
	}
	rewind(fp);
	buff = NULL;
	linesize = 0;
	while(mygetline(&buff,&linesize,fp) >= 0)
	{
		fputs(buff,stdout);	
	}

	fclose(fp);
	fclose(fps);

	exit(0);
}
